package com.yuchen.ishop.service.comment;

import com.yuchen.ishop.entity.Comment;
import com.yuchen.jaxrs.restclient.RestClientUtils;
import com.yuchen.utils.config.ConfigUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;


import java.util.Map;

/**
 * @author Jack Q
 */
@Service
public class CommentRestClient {

    private final static Logger LOG = Logger.getLogger(CommentRestClient.class);

    /**
     *
     * @param params (orderId:xxx,pageNo:xxx,pageSize:xxx)
     * @return
     */
    public  String find(Map params){
        String url = RestClientUtils.url(ConfigUtils.config.get("comment_find"),params);
        String json =  RestClientUtils.get(String.class, url);
        LOG.info(json);
        return json;
    }

    public  String add(Comment comment){
        String url = ConfigUtils.config.get("comment_add");
        String json =  RestClientUtils.post(String.class,comment,url);
        LOG.info(json);
        return json;
    }

    public  String update(Comment comment){
        String url = ConfigUtils.config.get("comment_update");
        String json =   RestClientUtils.post(String.class, comment, url);
        LOG.info(json);
        return json;
    }

}
